package com.nbgroup.service;

import com.nbgroup.dao.MenuRoleRepositoty;
import com.nbgroup.entity.MenuRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 18545 on 2019/7/15.
 */
@Service
public class MenuRoleService {
    @Autowired
    private MenuRoleRepositoty menuRoleRepositoty;

    public void saveMenuRole(String id,String ids){
        MenuRole roleId = menuRoleRepositoty.findByRoleId(Long.parseLong(id));
        if(roleId==null){
            MenuRole menuRole =new MenuRole();
            menuRole.setRoleId(Long.parseLong(id));
            menuRole.setMenuId(ids);
            menuRoleRepositoty.save(menuRole);
        }else {
            roleId.setMenuId(ids);
            menuRoleRepositoty.saveAndFlush(roleId);
        }

    }
}
